<template>
       <tr>
          <th>
            <input type="checkbox" /> <span></span>
          </th>
          <th>{{name}}</th>
          <th>{{price}}</th>
          <th>
            <button :disabled="flag" @click="sum">-</button>
            {{num}}
            <button @click="add">+</button>
            </th>
          <th>{{price*num}}</th>
          <th>
            <button @click="del">删除</button>
          </th>
        </tr>
</template>

<script>
export default {
    props: ["name", "price", "num", "index"],
    data() {
        return {
        flag: true
        };
    },
    methods: {
      add() {
        // console.log(11);
        this.$emit('changeCount', + 1,this.index);
        this.flag = false;
      },
      sum() {
        // console.log(22);
        this.$emit('changeCount', -1,this.index);
        if(this.num === 2) {
          this.flag= true
        }
      },
      del() {
        this.$emit("delet")
      }
    },
    computed: {

    },
    created() {

    },
    mounted() {

    },
    watch: {

    },
    components: {

    },
};
</script>

<style scoped lang="scss">

</style>
